import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.io.FileUtils;

public class StationInfoHelper {

	private static Map<String, String> stationCodeMap = new HashMap<String, String>();

	private static String[] stationNames;

	static {
		File stationInfoFile = new File(StationInfoHelper.class.getResource(
				"/station.txt").getPath());
		try {
			List<String> lines = FileUtils.readLines(stationInfoFile, "utf-8");
			stationNames = new String[lines.size()];
			for (int i = 0; i < lines.size(); i++) {
				String line = lines.get(i);
				String[] stationInfoArray = line.split("\\|");
				stationCodeMap.put(stationInfoArray[1], stationInfoArray[2]);
				stationNames[i] = stationInfoArray[1];
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static String[] getStationNames() {
		return stationNames;
	}

	public static String getStationCode(String stationName) {
		return stationCodeMap.get(stationName);
	}
}
